﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
namespace Chizx.Web.user
{
    public partial class Show : Page
    {        
        		public string strid=""; 
		protected void Page_Load(object sender, EventArgs e)
                {
                    if (null == Session["UserEntity"])
                    {
                        Response.Redirect("/e/Login.aspx");
                    }
			if (!Page.IsPostBack)
			{
                string zu_id = "";
                if (Request.Params["id0"] != null && Request.Params["id0"].Trim() != "")
                {
                    zu_id = Request.Params["id0"];
                }
                if (Request.Params["sign"] != null && Request.Params["sign"].Trim() == "zxxsb")
                {
                    ShowInfoDetail(zu_id);
                }
                else
                {
                    
                    int zc_id = -1;
                    if (Request.Params["id1"] != null && Request.Params["id1"].Trim() != "")
                    {
                        zc_id = (Convert.ToInt32(Request.Params["id1"]));
                    }
                    ShowInfo(zu_id, zc_id);
                }
			}
		}
		
	private void ShowInfo(string zu_id,int zc_id)
	{
        Chizx.BLL.UserBll bll = new Chizx.BLL.UserBll();
		Chizx.Model.UserModel model=bll.GetModel(zu_id,zc_id);
		this.lblzu_id.Text=model.zu_id;
		this.lblzc_id.Text=model.zc_id.ToString();
		this.lblzu_name.Text=model.zu_name;
		this.lblzu_pwd.Text=model.zu_pwd;
        this.lblzu_sex.Text = model.zu_sex == 0 ? "男" : (model.zu_sex == 1 ? "女" : "不详");
        this.lblzu_roles.Text = model.zu_roles == "SS" ? "学生" : (model.zu_roles == "SX" ? "实习生" : (model.zu_roles == "A1" ? "指导老师" : (model.zu_roles == "A2" ? "院系负责人" : (model.zu_roles == "A3" ? "教务管理员" : (model.zu_roles == "A0" ? "系统管理员" : "非法")))));
		this.lblzu_weixin.Text=model.zu_weixin;
		this.lblzu_qq.Text=model.zu_qq;
		this.lblzu_tel.Text=model.zu_tel;
		this.lblzu_email.Text=model.zu_email;
        this.lblzu_lastdate.Text = model.zu_lastdate == null ? "从未登录" : model.zu_lastdate;
        this.lblzu_lastip.Text = model.zu_lastip == null ? "从未登录" : model.zu_lastip;
		this.lblzu_createdate.Text=model.zu_createdate.ToString();
        this.lblzu_status.Text = model.zu_status == "u0" ? "在校中" : (model.zu_status == "u1" ? "实习中" : "未知状态");
        this.lblzu_direct.Text = model.zu_direct == "00" ? "暂未分配" : model.zu_direct;
        //写入系统日志
        if (Session["UserEntity"] == null)
        {
            Response.Redirect("/e/Login.aspx");
        }
        else
        {
            Chizx.Model.UserModel sbmmodel = (Chizx.Model.UserModel)Session["UserEntity"];
            Chizx.BLL.SystemLogBll sbll = new Chizx.BLL.SystemLogBll();
            Chizx.Model.SystemLogModel slm = new Chizx.Model.SystemLogModel();
            slm.zu_id = sbmmodel.zu_id;
            slm.zl_dowhen = DateTime.Now;
            slm.zl_dowhat = "查看用户信息";
            slm.zl_dotype = "2";//0:Test,1:Auth,2:Read,3:Write,4:Del,5:Inpor
            slm.zl_dodesc = "操作成功";
            sbll.Add(slm);
        }
	}

    private void ShowInfoDetail(string zu_id)
    {
        Chizx.BLL.UserBll bll = new Chizx.BLL.UserBll();
        Chizx.Model.UserModel model = bll.GetModelByID(zu_id);
        this.lblzu_id.Text = model.zu_id;
        this.lblzc_id.Text = model.zc_id.ToString();
        this.lblzu_name.Text = model.zu_name;
        this.lblzu_pwd.Text = model.zu_pwd;
        this.lblzu_sex.Text = model.zu_sex == 0 ? "男" : (model.zu_sex == 1 ? "女" : "不详");
        this.lblzu_roles.Text = model.zu_roles == "SS" ? "学生" : (model.zu_roles == "SX" ? "实习生" : (model.zu_roles == "A1" ? "指导老师" : (model.zu_roles == "A2" ? "院系负责人" : (model.zu_roles == "A3" ? "教务管理员" : (model.zu_roles == "A0" ? "系统管理员" : "非法")))));
        this.lblzu_weixin.Text = model.zu_weixin;
        this.lblzu_qq.Text = model.zu_qq;
        this.lblzu_tel.Text = model.zu_tel;
        this.lblzu_email.Text = model.zu_email;
        this.lblzu_lastdate.Text = model.zu_lastdate == null ? "从未登录" : model.zu_lastdate;
        this.lblzu_lastip.Text = model.zu_lastip == null ? "从未登录" : model.zu_lastip;
        this.lblzu_createdate.Text = model.zu_createdate.ToString();
        this.lblzu_status.Text = model.zu_status == "u0" ? "在校中" : (model.zu_status == "u1" ? "实习中" : "未知状态");
        this.lblzu_direct.Text = model.zu_direct == "00" ? "暂未分配" : model.zu_direct;
        //写入系统日志
        if (Session["UserEntity"] == null)
        {
            Response.Redirect("/e/Login.aspx");
        }
        else
        {
            Chizx.Model.UserModel sbmmodel = (Chizx.Model.UserModel)Session["UserEntity"];
            Chizx.BLL.SystemLogBll sbll = new Chizx.BLL.SystemLogBll();
            Chizx.Model.SystemLogModel slm = new Chizx.Model.SystemLogModel();
            slm.zu_id = sbmmodel.zu_id;
            slm.zl_dowhen = DateTime.Now;
            slm.zl_dowhat = "查看用户信息";
            slm.zl_dotype = "2";//0:Test,1:Auth,2:Read,3:Write,4:Del,5:Inpor
            slm.zl_dodesc = "操作成功";
            sbll.Add(slm);
        }
    }
    }
}
